package cn.com.dhcc.turbo.entity.registry.tlq;

import java.util.List;

import cn.com.dhcc.app.core.util.StrUtil;
import cn.com.dhcc.app.pub.core.consts.TlqConfig;
import cn.com.dhcc.turbo.entity.registry.Queue;

import com.tongtech.tlq.admin.conf.SendQue;
import com.tongtech.tlq.admin.conf.TlqConfException;

/**
 * 发送队列信息
 */
public class TlqSq extends Queue {
	private String queueName; 		//[名称 ]
	private String status;			//[状态 ]状态值参考 TLQOptBaseObj定义"OBJ_STATE"类成员
	private String configMsgNum;	//[配置消息数 ]
	private String usedMsgNum;  	//[使用消息数]
	private String remainMsgNum;	//[剩余消息数 ]
	private String mallocSpace;		//[所占空间 ](单位K)
	private String remainSpace;		//[剩余空间 ](单位K)
	private String existSendConn;	//[存在发送连接 ]0 代表发送连接没有配置；1 代表发送连接存在
	private String sendConnName;	//[对应发送连接 ]
	private String sendProcId;		//[发送进程ID ]
	private String linkType;		//[连接类型 ]TLQOptBaseObj定义"LINKTYPE"类成员
	private String linkIp;			//[连接IP ]
	private String linkPort;		//[连接端口 ]
	private String sendProcStatus;	//[发送进程状态 ]
	private String connStatus;		//[连接状态 ]TLQOptBaseObj定义"LINK_STATE"类成员
	private String linkStatus;		//[链路状态 ]
	private String toQueName;       //[目的节点]
	public TlqSq() {
	}

	@SuppressWarnings("rawtypes")
	public TlqSq(List list) {
		this.queueName = "" + list.get(0);
		this.status = "" + list.get(1);
		this.configMsgNum = "" + list.get(2);
		this.usedMsgNum = "" + list.get(3);
		this.remainMsgNum = "" + list.get(4);
		this.mallocSpace = "" + list.get(5);
		this.remainSpace = "" + list.get(6);
		this.existSendConn = "" + list.get(7);
		this.sendConnName = "" + list.get(8);
		this.sendProcId = "" + list.get(9);
		this.linkType = "" + list.get(10);
		this.linkIp = "" + list.get(11);
		this.linkPort = "" + list.get(12);
		this.sendProcStatus = "" + list.get(13);
		this.connStatus = "" + list.get(14);
		this.linkStatus = "" + list.get(15);
//		this.toQueName = "" + list.get(16);
	}
	
	
	/**
	 * 创建默认的本地队列
	 * @param queName
	 * @return
	 * @throws TlqConfException
	 * @throws IllegalArgumentException
	 */
	public SendQue toSendQueDefaultParam() throws TlqConfException, IllegalArgumentException {
		if (StrUtil.isBlank(this.getQueueName())) {
			throw new IllegalArgumentException("LocalQueName can't be null");
		}
		SendQue sq = new SendQue();
		sq.setSendQueName(this.getQueueName());
		sq.setMsgNum(TlqConfig.SQ.MSG_NUM);
		sq.setMsgSize(TlqConfig.SQ.MSG_SIZE);
		sq.setQueSpaceSize(TlqConfig.SQ.QUE_SPACE_SIZE);
		sq.setSendQDataBuff(TlqConfig.SQ.SENDQ_DATA_BUFF);
		sq.setDefPriority(TlqConfig.SQ.DEF_PRIORITY);
		sq.setDefPersistence(TlqConfig.SQ.DEF_PERSISTENCE);
		sq.setDefDestQueName(this.getDestQueueName());
		sq.setDeadFlag(TlqConfig.SQ.DEAD_FLAG);
		return sq;
	}

	public String getQueueName() {
		return queueName;
	}

	public String getStatus() {
		return status;
	}

	public String getConfigMsgNum() {
		return configMsgNum;
	}

	public String getUsedMsgNum() {
		return usedMsgNum;
	}

	public String getRemainMsgNum() {
		return remainMsgNum;
	}

	public String getMallocSpace() {
		return mallocSpace;
	}

	public String getRemainSpace() {
		return remainSpace;
	}

	public String getExistSendConn() {
		return existSendConn;
	}

	public String getSendConnName() {
		return sendConnName;
	}

	public String getSendProcId() {
		return sendProcId;
	}

	public String getLinkType() {
		return linkType;
	}

	public String getLinkIp() {
		return linkIp;
	}

	public String getLinkPort() {
		return linkPort;
	}

	public String getSendProcStatus() {
		return sendProcStatus;
	}

	public String getConnStatus() {
		return connStatus;
	}

	public String getLinkStatus() {
		return linkStatus;
	}

	public void setQueueName(String queueName) {
		this.queueName = queueName;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setConfigMsgNum(String configMsgNum) {
		this.configMsgNum = configMsgNum;
	}

	public void setUsedMsgNum(String usedMsgNum) {
		this.usedMsgNum = usedMsgNum;
	}

	public void setRemainMsgNum(String remainMsgNum) {
		this.remainMsgNum = remainMsgNum;
	}

	public void setMallocSpace(String mallocSpace) {
		this.mallocSpace = mallocSpace;
	}

	public void setRemainSpace(String remainSpace) {
		this.remainSpace = remainSpace;
	}

	public void setExistSendConn(String existSendConn) {
		this.existSendConn = existSendConn;
	}

	public void setSendConnName(String sendConnName) {
		this.sendConnName = sendConnName;
	}

	public void setSendProcId(String sendProcId) {
		this.sendProcId = sendProcId;
	}

	public void setLinkType(String linkType) {
		this.linkType = linkType;
	}

	public void setLinkIp(String linkIp) {
		this.linkIp = linkIp;
	}

	public void setLinkPort(String linkPort) {
		this.linkPort = linkPort;
	}

	public void setSendProcStatus(String sendProcStatus) {
		this.sendProcStatus = sendProcStatus;
	}

	public void setConnStatus(String connStatus) {
		this.connStatus = connStatus;
	}

	public void setLinkStatus(String linkStatus) {
		this.linkStatus = linkStatus;
	}

	public String getToQueName() {
		return toQueName;
	}

	public void setToQueName(String toQueName) {
		this.toQueName = toQueName;
	}

	@Override
	public String toString() {
		return "TlqSq [queueName=" + queueName + ", status=" + status + ", configMsgNum=" + configMsgNum
				+ ", usedMsgNum=" + usedMsgNum + ", remainMsgNum=" + remainMsgNum + ", mallocSpace=" + mallocSpace
				+ ", remainSpace=" + remainSpace + ", existSendConn=" + existSendConn + ", sendConnName="
				+ sendConnName + ", sendProcId=" + sendProcId + ", linkType=" + linkType + ", linkIp=" + linkIp
				+ ", linkPort=" + linkPort + ", sendProcStatus=" + sendProcStatus + ", connStatus=" + connStatus
				+ ", linkStatus=" + linkStatus + ", toQueName=" + toQueName + "]";
	}
}
